// components/basics/basics.js
// import Toast from 'path/to/@vant/weapp/dist/toast/toast';
// import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast'
import Toast from "../../miniprogram_npm/@vant/weapp/toast/toast"
 
console.log(Toast)
Page({

  /**
   * 页面的初始数据
   */
  data: {
    datas:[],
    data:[],
    myshow: false,
    telshow: false,
    newTel:"",
    newTelValue:"",
    newEmailValue:'',
    date:"",
    dateshow:false,
    birthdate:"",
    birthshow:false,
    dcolumns: ['博士', '研究生', '本科', '专科', '中专'],
    degshow:false,
    marshow:false,
    mcolumns:['已婚','未婚'],
    emailshow:false,
    nameValue:"",
    

  },

  showMar(){
    this.setData({
      marshow:true
    })
  },

  showDeg(){
    this.setData({ 
        degshow:true 
    })
  },

   
  getUserInfo(event) {
    console.log(event.detail);
  },

  onClose() {
    this.setData({ show: false });
  },
  
  onMarConfirm(event){
    console.log("婚姻");
    console.log(event.detail);
    const { value, index } = event.detail;
    Toast(`当前值：${value}, 当前索引：${index}`);
  },
  //覆盖本地storage
   upload(){
     let data=this.data.data
     wx.setStorage({
       data: data,
       key: 'userInfo',
     })
   },
   //刷新
   refresh(){
    wx.redirectTo({
      url: './basics',
    })
   },
  onDegreeConfirm(event) {
    let data = this.data.data;
    data.education= event.detail.value;
       wx.setStorage({
         data: data,
         key: 'userInfo',
       })
    // console.log("学历");
   
      wx.navigateTo({
        url: './basics',
      })
  

    // console.log(data,event.detail);
    const { value, index } = event.detail;
    // console.log(Toast);
    
    Toast(`当前值：${value}, 当前索引：${index}`);
  },

  onCancel() {
    Toast('取消');
  },

  getUserInfo(event) {
    console.log(event.detail);
  },
   
  showDialogTel(){
    this.setData({ myshow: true,telshow:true});
  },

  getuserEmail(event){
    console.log(111,event.detail);
  },
   
  onClose() {
    this.setData({ show: false });
    console.log(1111);
  },


  showDialogEmail(){
    this.setData({  emailshow:true });
  },
  // 时间
  onDisplay() {
    this.setData({ dateshow: true  });
    // console.log("hhh");
  },

  onBirthDisplay() {
    this.setData({birthshow:true });
    console.log("hhh111");
  },

 
  onWorkClose() {
    this.setData({ dateshow: false});
  },

  
  onBirthClose() {
    this.setData({ birthshow: false});
  },


  formatDate(date) {
    // date = new Date(date);
    date =  new Date(date) ;
    // return `${date.getMonth() + 1}/${date.getDate()}`;
    let year = date.getFullYear();
    let month = date.getMonth() + 1;
    let day = date.getDate();
    return year + '年' + month + '月' + day + '日';
    
  },

  onWorkConfirm(event) {
    console.log("wwww"); 
    const [start, end] = event.detail;
    console.log('124', event.detail); 
    this.setData({
      dateshow: false, 
      date:this.formatDate(event.detail)
    });
  },

  onBirthConfirm(event) {
    this.setData({
      birthshow: false,
      birthdate: this.formatDate(event.detail1),
    });
  },

 
  
  onTelChange(event) {
    // event.detail 为当前输入的值
    console.log(event.detail);
    // console.log(this);
    this.data.nameValue = this.data.newTelValue;
    console.log(this.data.nameValue);
    this.setData({
      nameValue:this.data.nameValue
    })
  },
  onEmailChange(event){
      // event.detail 为当前输入的值
      console.log(event.detail);
  },

  created(){
    console.log("hhh");
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    var data = wx.getStorageSync('userInfo');
    
    this.setData({
        data:data
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    console.log("hhhh");
   
   
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})